package com.jixiantubu.wode;

import java.util.ArrayList;
import java.util.List;
import com.example.jixiantubu.R;
import com.jixiantubu.util.MyApplication;

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class Wo_tieziActivity extends Activity implements OnClickListener{
	
	TextView wo_tiezi,wo_huifutie;
	FragmentManager fragmentManager;
	FragmentTransaction fragmentTransaction;
	Bundle bundle;
	String username;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Window window = this.getWindow();
		window.requestFeature(window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_wo_tiezi);
		initView();		
		init();
	}
	private void initView() {
		wo_tiezi=(TextView) findViewById(R.id.wo_fadetie);
		wo_huifutie=(TextView) findViewById(R.id.wo_huifudetie);
		
		wo_tiezi.setOnClickListener(this);
		wo_huifutie.setOnClickListener(this);
		Intent intent=getIntent();
		username=intent.getStringExtra("username");
		Log.e("<>>>>>>>>>>", username);
		if (username.equals(MyApplication.username)) {
			wo_tiezi.setText("我发布的");
			wo_huifutie.setText("我回复的");
		}else{
			wo_tiezi.setText("他发布的");
			wo_huifutie.setText("他回复的");
		}
	}

	@SuppressLint("NewApi")
	private void init() {
		fragmentManager=getFragmentManager();
		fragmentTransaction=fragmentManager.beginTransaction();
		WofabutieFragment fragment=new WofabutieFragment();
		 bundle = new Bundle();
		 bundle.putString("username", username);
		  fragment.setArguments(bundle);
		//替换主布局中的id是container的布局
		fragmentTransaction.replace(R.id.container111, fragment);
		fragmentTransaction.commit();
	}

	

	@SuppressLint("NewApi")
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		
		case R.id.wo_fadetie:
			fragmentManager=getFragmentManager();
			fragmentTransaction=fragmentManager.beginTransaction();
			WofabutieFragment fragment1=new WofabutieFragment();
			 bundle = new Bundle();
			 bundle.putString("username", username);
			  fragment1.setArguments(bundle);
			//替换主布局中的id是container的布局
			fragmentTransaction.replace(R.id.container111, fragment1);
			fragmentTransaction.commit();
			break;
		case R.id.wo_huifudetie:
			fragmentManager=getFragmentManager();
			fragmentTransaction=fragmentManager.beginTransaction();
			WohuifutieaFragment fragment=new WohuifutieaFragment();
			 bundle = new Bundle();
			 bundle.putString("username", username);
			  fragment.setArguments(bundle);
			//替换主布局中的id是container的布局
			fragmentTransaction.replace(R.id.container111, fragment);
			fragmentTransaction.commit();
			break;
		default:
			break;
		}
		
	}
	
	 
	 
}
